#include <matrix.hpp>

#include <boost/lambda/lambda.hpp>

#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;
using namespace boost::lambda;
using namespace sm;


int main()
{
	dynamic_matrix<int> a(10, 10);

	int i = 0;
	std::for_each( a.begin(), a.end(), _1=var(i)++ );

	cout << "a:\n" << a << "\n";

	typedef dynamic_matrix<int>::range_type rt;
	dynamic_matrix<int> b( a, rt(3, 5), rt(4,9));

	cout << "a[3,5][4,9] -> b:\n" << b << "\n";

	cout << "\nb.size() is " << b.size();
	cout << "\nb.row() and b.col() are " << b.row() << "\t" << b.col() << "\n";

	cout << "\nTEST || <- ROW MERGE\n";

	i=0;
	dynamic_matrix<int> x(3, 5);
	dynamic_matrix<int> y(3, 7);
	std::for_each( x.begin(), x.end(), _1=var(i)++ );
	std::for_each( y.begin(), y.end(), _1=var(i)++ );
	dynamic_matrix<int> z = x || y;

	cout 	<< "\nx is \n" << x
			<< "\ny is \n" << y
			<< "\nx||y is \n" << z;
	
	cout << "\nTEST && <- COL MERGE\n";
	i=0;
	dynamic_matrix<int> xx(5, 6);
	dynamic_matrix<int> yy(7, 6);
	std::for_each( xx.begin(), xx.end(), _1=var(i)++ );
	std::for_each( yy.begin(), yy.end(), _1=var(i)++ );
	dynamic_matrix<int> zz = xx && yy;

	cout 	<< "\nxy is \n" << xx
			<< "\nyy is \n" << yy
			<< "\nxx||yy is \n" << zz;


	cout << "\nCOL TEST:\n";

	i = 0;

	dynamic_matrix<int> u(10, 15);

	for_each( u.begin(), u.end(), _1=var(i)++);

	cout << "\nu:\n" << u << "\n";

	for ( std::size_t i = 0; i < 15; ++i )
	{
		copy( u.col_begin(i), u.col_end(i), ostream_iterator<int>(cout,"\t"));
		cout << "\n";
	}

	return 0;
}

